package com.jboost.common.util;

import org.springframework.core.io.ClassPathResource;

import java.io.*;

public class FileUtils {
    public static String readTxt(File file) throws IOException {
        String s = "";
        InputStreamReader in = new InputStreamReader(new FileInputStream(file),"UTF-8");
        BufferedReader br = new BufferedReader(in);
        StringBuffer content = new StringBuffer();
        while ((s=br.readLine())!=null){
            content = content.append(s);
        }
        return content.toString();
    }
    public static String readClassPathTxt(String resourcesPath) throws IOException {
        File file = new ClassPathResource(resourcesPath).getFile();
        return readTxt(file);
    }

}
